home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Demos / Tools / AppMaker / Examples / pre-built AMReminder / PowerPlant / CMainWindow.cp < prev    next >
Encoding:
Text File  |  1994-11-03  |  3.4 KB  |  200 lines  |  [TEXT/MMCC]

  1. // CMainWindow.cp -- window methods
  2. // Created 01/01/95 12:01 PM by AppMaker
  3.  
  4. #include "CMainWindow.h"
  5.  
  6. #include "CAdd.h"
  7.  
  8. #include "CAMReminderData.h"
  9. #include <UReanimator.h>
  10. #include <LStream.h>
  11. #include <LListBox.h>
  12. #include <LStdControl.h>
  13.  
  14. #define PPob_MainWindowID    200
  15. #define RidL_MainWindowID    200
  16.  
  17. //----------
  18. CMainWindow*
  19. CMainWindow::CreateMainWindow(
  20.     LCommander            *inSuperCommander,
  21.     CAMReminderData        *inData)
  22. {
  23.     CMainWindow        *window;
  24.  
  25.     window = (CMainWindow *)LWindow::CreateWindow(PPob_MainWindowID, inSuperCommander);
  26.     window->mData = inData;
  27.  
  28.     return window;
  29. }
  30.  
  31. //----------
  32. //    This is the function you register with URegistrar to create a
  33. //    CMainWindow from a resource
  34.  
  35. CMainWindow*
  36. CMainWindow::CreateMainWindowStream(
  37.     LStream    *inStream)
  38. {
  39.     return (new CMainWindow(inStream));
  40. }
  41.  
  42. //----------
  43. CMainWindow::CMainWindow()
  44. {
  45. }
  46.  
  47. //----------
  48. CMainWindow::CMainWindow(
  49.     LStream    *inStream)
  50.         : LWindow(inStream)
  51. {
  52. }
  53.  
  54. //----------
  55. CMainWindow::~CMainWindow()
  56. {
  57. }
  58.  
  59. //----------
  60. //    This member function gets called once the containment hierarchy that contains
  61. //    this pane has been built. It gives us a chance to get data members for
  62. //    interesting subviews, and to do other operations now that our subviews exist.
  63. void
  64. CMainWindow::FinishCreateSelf()
  65. {
  66.     mRemindersList = (LListBox *)FindPaneByID('Remi');
  67.     mAddButton = (LStdButton *)FindPaneByID('Add ');
  68.     mEditButton = (LStdButton *)FindPaneByID('Edit');
  69.     mDeleteButton = (LStdButton *)FindPaneByID('Dele');
  70.  
  71.     UReanimator::LinkListenerToControls(this, this, RidL_MainWindowID);
  72.         // the purpose is to "connect" self to whatever controls
  73.         // that we want to "listen" to
  74.  
  75. // any additional initialization for your window:
  76.  
  77. }
  78.  
  79. //----------
  80. void
  81. CMainWindow::DoAddReminder()
  82. {
  83.     CAdd::CreateAdd(this);
  84. }
  85.  
  86. //----------
  87. void
  88. CMainWindow::DoEditReminder()
  89. {
  90.     CAdd::CreateAdd(this);
  91. }
  92.  
  93. //----------
  94. void
  95. CMainWindow::DoDeleteReminder()
  96. {
  97.  
  98. }
  99.  
  100. //----------
  101. void
  102. CMainWindow::ListenToMessage(
  103.     MessageT    inMessage,
  104.     void        *ioParam)
  105. {
  106.     switch (inMessage) {
  107.     case 'Addr':
  108.             DoAddReminder();
  109.         break;
  110.  
  111.     case 'Edir':
  112.             DoEditReminder();
  113.         break;
  114.  
  115.     case 'Delr':
  116.             DoDeleteReminder();
  117.         break;
  118.  
  119.     default:
  120.         break;
  121.     }
  122. }
  123.  
  124. //----------
  125. void
  126. CMainWindow::ObeyAdd    (CAdd        *dialog)
  127. {
  128.     // get values from dialog; do something with them
  129.  
  130.     delete dialog;
  131. }
  132.  
  133. //----------
  134. Boolean
  135. CMainWindow::ObeyCommand(
  136.     CommandT    inCommand,
  137.     void        *ioParam)
  138. {
  139.     Boolean        cmdHandled = true;
  140.  
  141.     switch (inCommand) {
  142.  
  143.     // +++ Add cases here for the commands you handle
  144.     //        Remember to add same cases to FindCommandStatus below
  145.     //        to enable/disable the commands
  146.  
  147.     case cmd_Add:
  148.             ObeyAdd ((CAdd *)ioParam);
  149.         break;
  150.  
  151.     default:
  152.             cmdHandled = LWindow::ObeyCommand(inCommand, ioParam);
  153.         break;
  154.     }
  155.  
  156.     return cmdHandled;
  157. }
  158.  
  159. //----------
  160. void
  161. CMainWindow::FindCommandStatus(
  162.     CommandT    inCommand,
  163.     Boolean        &outEnabled,
  164.     Boolean        &outUsesMark,
  165.     Char16        &outMark,
  166.     Str255        outName)
  167. {
  168.     outUsesMark = false;
  169.  
  170.     switch (inCommand) {
  171.  
  172.     // +++ Add cases here for the commands you handle
  173.  
  174.     default:
  175.             LWindow::FindCommandStatus(inCommand, outEnabled,
  176.                                         outUsesMark, outMark, outName);
  177.         break;
  178.     }
  179. }
  180.  
  181. //----------
  182. Boolean
  183. CMainWindow::FocusDraw()
  184. {
  185.     Boolean        focused = LView::FocusDraw();
  186.  
  187.     if (focused) {
  188.         AuxWinHandle    awHndl;
  189.         CTabHandle        awCTable;
  190.         ColorSpec        contentSpec;
  191.  
  192.         GetAuxWin(GetMacPort(), &awHndl);
  193.         awCTable = (**awHndl).awCTable;
  194.         contentSpec = (**awCTable).ctTable [wContentColor];        // should search vs. index
  195.         ::RGBBackColor(&contentSpec.rgb);
  196.     }
  197.  
  198.     return focused;
  199. }
  200.